class Solution {
public:
    int halveArray(vector<int>& nums) {
        priority_queue<double> p;
        double a1=0;
        double a2=0;
        for(auto& a:nums)
        {
            a1+=a;
            a2+=a;
            p.push(a);
        }
        a1/=2;
        int mem=0;
        while(a1<a2)
        {
            double tmp=p.top()/2;
            p.pop();
            a2-=tmp;
            p.push(tmp);
            mem++;
        }
        return mem;
    }
};
